from typing import Optional
from pydantic import BaseModel, field_validator

from .flow_data import FlowData

class FlowUpdate(BaseModel):
    name: Optional[str] = None
    description: Optional[str] = None
    flow: Optional[FlowData] = None

    @field_validator("name")
    @classmethod
    def _validate_name(cls, v: Optional[str]) -> Optional[str]:
        if v is None:
            return v
        vv = v.strip()
        if not vv:
            raise ValueError("name must not be empty when provided")
        return vv